package com.hyt.it.ogt.kq.service.gov.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyt.core.base.BaseServiceImpl;
import com.hyt.it.ogt.kq.service.bm.service.IDictService;
import com.hyt.it.ogt.kq.service.gov.mapper.AgreementMapper;
import com.hyt.it.ogt.kq.service.gov.mapper.BehaviorAnalysisMapper;
import com.hyt.it.ogt.kq.service.gov.model.entity.Agreement;
import com.hyt.it.ogt.kq.service.gov.model.entity.BehaviorAnalysis;
import com.hyt.it.ogt.kq.service.gov.model.entity.Dict;
import com.hyt.it.ogt.kq.service.gov.model.param.BehaviorAnalysisParam;
import com.hyt.it.ogt.kq.service.gov.model.vo.BehaviorAnalysisPageVo;
import com.hyt.it.ogt.kq.service.gov.model.vo.CandidatePageVO;
import com.hyt.it.ogt.kq.service.gov.service.GovIDictService;
import com.hyt.it.ogt.kq.service.gov.service.IAgreementService;
import com.hyt.it.ogt.kq.service.gov.service.IBehaviorAnalysisService;
import com.hyt.model.PageParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class BehaviorAnalysisImpl extends BaseServiceImpl<BehaviorAnalysisMapper, BehaviorAnalysis> implements IBehaviorAnalysisService {
    @Resource
    BehaviorAnalysisMapper mapper;
    @Resource
    GovIDictService iDictService;
    @Override
    public Page<BehaviorAnalysisPageVo> queryPage(PageParam<BehaviorAnalysisPageVo> pageParam, BehaviorAnalysisParam param) {
        Page<BehaviorAnalysisPageVo> page = mapper.queryPage(pageParam,param);
        List<BehaviorAnalysisPageVo> records = page.getRecords();
        if (records.isEmpty()) {
            return page;
        }
        Map<String, Dict> mapDict = iDictService.getCardTypeDict();

        // 处理分页数据
        records.stream().forEach(pageVO -> {
            pageVO.setIdTypeName(mapDict.get(String.valueOf(pageVO.getIdType())).getLabel());
            if("1".equals(pageVO.getBehaviorType())){
                pageVO.setBehaviorTypeName("长期未作答");
            }else if("2".equals(pageVO.getBehaviorType())){
                pageVO.setBehaviorTypeName("密集作答");
            }else if("3".equals(pageVO.getBehaviorType())){
                pageVO.setBehaviorTypeName("密集翻页");
            }else{
                pageVO.setBehaviorTypeName("大量修改");
            }
        });
        return page;
    }
}
